package com.pignest.hotel.module.global;

import java.util.List;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.util.GenericAutowireComposer;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listhead;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.Textbox;
import org.zkoss.zul.Window;

import com.pignest.hotel.beans.User;
import com.pignest.hotel.beans.Member;
import com.pignest.hotel.module.user.ui.ModelListHead;
import com.pignest.hotel.service.MemberService;
import com.pignest.hotel.spring.Services;
import com.pignest.hotel.util.DateUtil;
import com.pignest.hotel.util.WhereCreator;

public class SelectMemberWindow extends GenericAutowireComposer {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2133339397577318992L;

	private Textbox nameField;//会员姓名

	
	private Textbox mobileField;//手机

	
	private Textbox mailField;//邮件
	
	
	private Textbox cardNoField;//卡号
	
	private Listbox memberListbox;
	
	private MemberService memberService;
	public SelectMemberWindow(){
		
		memberService=Services.getMemberService();
	}
	public Textbox getNameField() {
		return nameField;
	}
	public void setNameField(Textbox nameField) {
		this.nameField = nameField;
	}
	public Textbox getMobileField() {
		return mobileField;
	}
	public void setMobileField(Textbox mobileField) {
		System.out.println("********************************");
		this.mobileField = mobileField;
	}
	public Textbox getMailField() {
		return mailField;
	}
	public void setMailField(Textbox mailField) {
		this.mailField = mailField;
	}
	public Textbox getCardNoField() {
		return cardNoField;
	}
	public void setCardNoField(Textbox cardNoField) {
		this.cardNoField = cardNoField;
	}
	public void onCreate() {
		
		this.Query();
	}
	public void doAfterCompose(Component comp) throws Exception {
		super.doAfterCompose(comp);
	}
	
public void Query(){
	System.out.println("query:"+this.getMobileField().getValue());
	   this.setHead();
		StringBuffer hql=new StringBuffer();
		WhereCreator where =new WhereCreator();
		hql.append(" from Member b where 1=1 ");
	
		List<Member> memberList =memberService.find(hql.toString());
		for(int i=0;i<memberList.size();i++){
			final Member member = memberList.get(i);
			Listitem listitem = new Listitem();
			
			listitem.setValue(member.getId());
			listitem.setParent(memberListbox);
			listitem.appendChild(new Listcell(Integer.toString(i+1)));
			listitem.appendChild(new Listcell(member.getName()));
			listitem.appendChild(new Listcell(member.getType()));
			listitem.appendChild(new Listcell(member.getSex()));
			listitem.appendChild(new Listcell(member.getMobile()));

			listitem.appendChild(new Listcell(member.getMail()));

			listitem.appendChild(new Listcell(member.getNation()));
			listitem.appendChild(new Listcell(member.getProvince()));

		
		}
	}
public void setHead(){
	ModelListHead modelhead = new ModelListHead();
	Listhead head = modelhead.memberListHead(memberListbox);
}


}
